/* GUI CONVERTED from rcrshup.p (converter v1.75) Sat Aug 12 23:00:48 2000 */
/* rcrshup.p - Customer Schedules : Update Ship-From Database Schedule  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 7.3    LAST MODIFIED: 08/13/93           BY: WUG *GE19*    */
/* REVISION: 7.3    LAST MODIFIED: 04/11/95           BY: ame *F0QB*    */
/* REVISION: 7.3    LAST MODIFIED: 08/02/95           BY: bcm *G0TB*    */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan */
/* REVISION: 8.6E   LAST MODIFIED: 01/19/2000         BY: *J3NH* Ashwini G  */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00           BY: *N0KP* myb        */


/* UPDATE REMOTE DATABASE SCHEDULE */

/*J3NH*/ /* REPLACED THE LOGIC OF COPYING THROUGH 'NULL' STREAM BY */
/*J3NH*/ /* BUFFER-COPY STATEMENT                                  */

/*F0QB*/  {mfdeclre.i}

          define input parameter sch_recid as recid.

/*J3NH**  define new shared frame hf_sch_mstr. */
/*J3NH**  define new shared frame hf_schd_det. */
/*J3NH**  define stream nullstream.            */
          define variable old_db as character.
/*F0QB*/  define variable sdb_err as integer no-undo.
/*J3NH*/  define new shared workfile work_sch_mstr no-undo like sch_mstr.
/*J3NH*/  define new shared workfile work_schd_det no-undo like schd_det.

/*F0QB*   {mfdeclre.i}*/

/*J3NH**      form sch_mstr with frame hf_sch_mstr. */
/*J3NH**      form schd_det with frame hf_schd_det. */

/*J3NH*/ for each work_sch_mstr exclusive-lock:
/*J3NH*/    delete work_sch_mstr.
/*J3NH*/ end. /* FOR EACH WORK_SCH_MSTR */

          find sch_mstr where recid(sch_mstr) = sch_recid no-lock.

          find sod_det where sod_nbr = sch_nbr and sod_line = sch_line
          no-lock.


/*G0TB*/  /* WE NEED TO USE THE sod_det INFORMATION SINCE THE HEADER
         SITE REPRESENTS THE AR SITE IN CUSTOMER SCHEDULES */
/*G0TB*/  find si_mstr where si_site = sod_site no-lock.

/*G0TB**  find so_mstr where so_nbr = sod_nbr no-lock.  **/
/*G0TB**  find si_mstr where si_site = so_site no-lock. **/

      if si_db <> global_db then do:
         old_db = global_db.
/*F0QB*      create alias qaddb for database value(si_db).*/
/*F0QB*      global_db = si_db.*/
/*F0QB*/     {gprun.i ""gpalias3.p"" "(input si_db, output sdb_err)"}
/*GUI*/ if global-beam-me-up then undo, leave.



         /* DELETE SCHEDULE FROM REMOTE DB */

/*J3NH*/ /* QUALIFIED THE FIRST FOUR INPUT PARAMETERS BY SCH_MSTR. */
          {gprun.i ""rcschdla.p""
             "(input sch_mstr.sch_type,
               input sch_mstr.sch_nbr,
               input sch_mstr.sch_line,
               input sch_mstr.sch_rlse_id,
               input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /* COPY SCHEDULE MASTER TO REMOTE DB */

/*J3NH** {mfoutnul.i &stream_name=nullstream}                        */
/*J3NH**  display stream nullstream sch_mstr with frame hf_sch_mstr. */

/*J3NH*/  create work_sch_mstr .
/*J3NH*/  buffer-copy sch_mstr to work_sch_mstr.
/*J3NH*/  if recid(work_sch_mstr) = -1 then .

         {gprun.i ""rcrshupa.p""}
/*GUI*/ if global-beam-me-up then undo, leave.



         /* COPY SCHEDULE DETAIL TO REMOTE DB */
/*J3NH** BEGIN DELETE **
 *        for each schd_det no-lock
 *           where schd_type    = sch_type
 *             and schd_nbr     = sch_nbr
 *             and schd_line    = sch_line
 *             and schd_rlse_id = sch_rlse_id:
 *       disp stream nullstream schd_det with frame hf_schd_det.
 *J3NH** END DELETE **/

/*J3NH*/  for each schd_det no-lock
/*J3NH*/     where schd_type    = work_sch_mstr.sch_type
/*J3NH*/       and schd_nbr     = work_sch_mstr.sch_nbr
/*J3NH*/       and schd_line    = work_sch_mstr.sch_line
/*J3NH*/       and schd_rlse_id = work_sch_mstr.sch_rlse_id:
/*GUI*/ if global-beam-me-up then undo, leave.

/*J3NH*/     create work_schd_det.
/*J3NH*/     buffer-copy schd_det to work_schd_det.
/*J3NH*/     if recid(work_schd_det) = -1 then.

             {gprun.i ""rcrshupb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

          end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* for  each schd_det */

/*F0QB*      create alias qaddb for database value(old_db).*/
/*F0QB*      global_db = old_db.*/
/*F0QB*/     {gprun.i ""gpalias3.p"" "(input old_db, output sdb_err)"}
/*GUI*/ if global-beam-me-up then undo, leave.


/*J3NH**     output stream nullstream close. */
      end.
